
using System;
using System.Collections;
using System.Web.UI.WebControls;

using Awaken.Framework;
using Nullables;

namespace Northwind.Domain.Entities
{
    public partial class Category : IEntity
    {
        protected static CategoryBroker broker;
        public static CategoryBroker Broker
        {
            get
            {
                if (broker == null)
                {
                    broker = new CategoryBroker();
                }
                return broker;
            }
        }

        #region IEntity Members

        public string EntityID
        {
            get { return string.Empty; }
        }
        
        public string EntityName
        {
            get { return string.Empty; }
        }

        public void Save()
        {
            Broker.Save(this);
        }
        
        public void Delete()
        {
            Broker.Delete(this);
        }
        
        #endregion
    
        #region Constructor
        
        public Category()
        {
            // Default, no arg constructor.
        }
        
        #endregion
            
        #region Public Properties / Protected Fields
                        
        
        protected System.Int32? _CategoryID;
        public System.Int32? CategoryID
        {
            get{ return _CategoryID; }
            set{ _CategoryID=value; }
        }
        
        protected string _CategoryName;
        public string CategoryName
        {
            get{ return _CategoryName; }
            set{ _CategoryName=value; }
        }
        
        protected string _Description;
        public string Description
        {
            get{ return _Description; }
            set{ _Description=value; }
        }
        
        protected byte[] _Picture;
        public byte[] Picture
        {
            get{ return _Picture; }
            set{ _Picture=value; }
        }
        
        
        
        // One-To-Many: Products.CategoryID  
        protected IList _ProductList;
        public IList ProductList
        {
            get{ return _ProductList; }
            set{ _ProductList=value; }
        }
        
        
                
        
        
        
        #endregion
    }
    
    #region CategoryBroker

    public partial class CategoryBroker : IBroker
    {
        #region IBroker Members

        public Type EntityType
        {
            get { return typeof(Category); }
        }
        
        public Category GetByID(object id)
        {
            return (Category)Awaken.Framework.Gateway.GetByID(EntityType, id);
        }

        public IList GetAll()
        {
            return Awaken.Framework.Gateway.GetAll(EntityType);
        }

        public void Save(IEntity entity)
        {
            Awaken.Framework.Gateway.Save(entity);
        }
        
        public void Delete(IEntity entity)
        {
            Awaken.Framework.Gateway.Delete(entity);
        }
        
        #endregion
    }
    #endregion
}
